package com.yanqu.road.server.cmd.beautyescort;

import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.PreReduceModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

@Cmd(code = Protocol.S_BEAUTY_ESCORT_ROAD_MAP_REFRESH_FROM_CROSS, desc = "押镖路线")
public class BeautyEscortRoadMapCmdFromCross extends AbstractCommand {

    int crossRet;
    int type;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BeautyEscortProto.CrossBeautyEscortRoadMapRespMsg reqMsg = BeautyEscortProto.CrossBeautyEscortRoadMapRespMsg.parseFrom(packet.getBytes());
        crossRet = reqMsg.getRet();
        type = reqMsg.getType();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if(type == 1){
            //刷新消耗
            player.getModule(PreReduceModule.class).restorePreReduce(GameConfig.ESCORT_REFRESH_CAR_CONSUME);

            Property consume = PropertyHelper.parseStringToProperty(GameConfig.ESCORT_REFRESH_CAR_CONSUME);
            player.getModule(CurrencyModule.class).removeCurrency(consume, eLogMoneyType.BeautyEscort, eLogMoneyType.BeautyEscortRefreshConsume);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
